<?php



defined('BASEPATH') OR exit('No direct script access allowed');

include 'linkdatabase.php';
include 'findInDatabase.php';


class Confirm extends CI_Controller {
  public function index(){
		$type=$_GET['type'];
		$name=$_GET['name'];
    $openId=$_GET['openId'];
    $status="已完成";
		
    $link = linkdatabase::link();
    @mysqli_select_db($link, "witkey");

		if($type==1){
      $uid=findInDatabase::finduid($openId);
      $sql="UPDATE mission SET `m_state`='$status' WHERE `m_name`='$name' AND `u_id`='$uid'";
		  $result = mysqli_query($link, $sql);
      if(!$result){
        echo 'gg';
      }else{
        $data="success";
			  header(	'Content-Type:text/json');
			  echo json_encode($data);
      }
		}else{
       $uid=findInDatabase::finduid($openId);
      $sql="UPDATE buybook SET `status`='$status' WHERE `title`='$name' AND `uid`='$uid'";
		  $result = mysqli_query($link, $sql);
      if(!$result){
        echo 'gg';
      }else{
        $data="success";
			  header(	'Content-Type:text/json');
			  echo json_encode($data);
      }
		}


			

  }
}